/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hhf.worldzones.services.locationServices.countryServices;

import hhf.flex.annotations.FlexDestination;
import hhf.worldzones.daos.CountryDAO;
import hhf.worldzones.entities.Country;
import hhf.worldzones.entities.Region;
import hhf.worldzones.exceptions.CountryUnknownException;
import hhf.worldzones.exceptions.EntityUnknownException;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.inject.Inject;
import org.slf4j.Logger;

/**
 *
 * @author HHFrancois
 */
@Stateless
public class CountryFacade implements CountryFacadeLocal {

    @Inject
    Logger logger;
    @EJB
    CountryDAO countryDAO;

    @Override
    public void remove(Country entity) {
        logger.debug("remove Country : " + entity.getLabel());
        //countryDAO.remove(entity);
    }

    @Override
    public void persist(Country entity) {
        logger.debug("persist Country : " + entity.getLabel());
        //countryDAO.persist(entity);
    }

    @Override
    public Country merge(Country entity) {
        return countryDAO.merge(entity);
    }

    @Override
    public List<Country> findRange(int[] range) {
        return countryDAO.findRange(range);
    }

    @Override
    public List<Country> findAll() {
        return countryDAO.findAll();
    }

    @Override
    public int count() {
        return countryDAO.count();
    }

    @Override
    public Country find(String id) throws CountryUnknownException {
        Country c;
        try {
            c = countryDAO.find(id);
        } catch (EntityUnknownException ex) {
            throw new CountryUnknownException(ex);
        }
        c.getRegions().size();
        return c;
    }

    @Override
    public void test(Country country, Region region, Country country2) {
    }
}
